{subtemplate common/header}
<link rel="stylesheet" type="text/css" href="source/plugin/acan_weixin/template/css/main.css" />
<div class="mn" style="padding-top:20px;">
 
<div class="bm" style="padding:0 0 20px;">

<div class="bm_h bbs">
<h3 class="xs2">{lang acan_weixin:bindweixin}</h3></div>
<ul class="tb cl whole pt20">{lang acan_weixin:weixinuser}{$info->username}
<li id="one1" class="a" onclick="acan_setTab('one',1,2)"><a href="javascript:;">{lang acan_weixin:bindolduser}</a></li>
<li id="one2" onclick="acan_setTab('one',2,2)"><a href="javascript:;">{lang acan_weixin:bindnewuser}</a></li></ul>
<div id="con_one_1" class="whole">
<form id="binda" name="binda" action='plugin.php?id=acan_weixin:callback&op=bind&style=0' method="post">

<table style="margin-top:20px" width="100%">
<tr>
	<td class="tdside tdborder">{lang acan_weixin:username}</td>
	<td colspan="2" class="tdborder tdvalue"><input type="text" name="save[username]" id="nameone1" value="" class="tdinput" /><span class="rq">*</span></td>
</tr>
<tr>
	<td class="tdside tdborder">{lang acan_weixin:password}</td>
	<td colspan="2" class="tdborder tdvalue"><input type="password" name="save[password]" value="" class="tdinput" /><span class="rq">*</span></td>
</tr>
<tr>
	<td colspan="3" align="center"><input type="button" class="pn pnc" value=" {lang acan_weixin:submit} " onclick="acan_bind('binda')" style="width:50px;margin:30px" /></td>
</tr>
</table>
</form>
</div>
<div id="con_one_2" class="whole" style="display:none">
<form id="bindb" name="bindb" action='plugin.php?id=acan_weixin:callback&op=bind&style=1' method="post">

<table style="margin-top:20px" width="100%">
<tr>
	<td class="tdside tdborder">{lang acan_weixin:username}</td>
	<td colspan="2" class="tdborder tdvalue"><input type="text" name="save[username]" class="tdinput" id="nameone2" value="{$info->username}" /><span class="rq">*</span></td>
</tr>
<tr>
	<td class="tdside tdborder">{lang acan_weixin:password}</td>
	<td colspan="2" class="tdborder tdvalue"><input type="password" name="save[password]" id="psdone2" value="" class="tdinput" /><span class="rq">*</span></td>
</tr>
<tr>
	<td class="tdside tdborder">{lang acan_weixin:repassword}</td>
	<td colspan="2" class="tdborder tdvalue"><input type="password" name="password" value="" class="tdinput" /><span class="rq">*</span></td>
</tr>
<tr>
	<td class="tdside tdborder">{lang acan_weixin:email}</td>
	<td colspan="2" class="tdborder tdvalue"><input type="text" name="save[email]" value="" class="tdinput" /><span class="rq">*</span></td>
</tr>
<tr>
	<td colspan="3" align="center"><input type="button" class="pn pnc" value=" {lang acan_weixin:submit} " onclick="acan_bind('bindb')" style="width:50px;margin:30px" /></td>
</tr>
</table>
</form>
</div>
</div></div>
<div id="bind_status" style="display:none"></div>
<script type="text/javascript">
	acan_setTab('one', 2, 2);
	function acan_setTab(name, cursel, n) {
		for(i=1; i<=n; i++){
			var menu = document.getElementById(name + i);
			var con = document.getElementById("con_" + name + "_" + i);
			menu.className = (i == cursel ? "a" : "");
			con.style.display = (i == cursel ? "block" : "none");
		}
		if(cursel == '1') {
			$('name' + name + cursel).focus();
		}
		else {
			$('psd' + name + cursel).focus();
		}
	}
	function acan_bind(formid) {
		$('bind_status').innerHTML = '';
		if(checkblank(formid) == false){
			showDialog('{lang acan_weixin:typeall}');
			return;
		}
		ajaxpost(formid, 'bind_status', 'bind_status', '', '', acan_bind_back);
	}
	function acan_bind_back() {
		var res = $('bind_status').innerHTML;
		switch(res) {
			case '-1':
				showDialog('{lang acan_weixin:illegal_post}', 'alert');
				break;
			case '0':
				showDialog('{lang acan_weixin:bindsuccess}', 'right', '', redirect);
				break;
			case '1'://user not found
				showDialog('{lang acan_weixin:bindfailure}{lang acan_weixin:usernotfound}', 'alert');
				break;
			case '2'://wrong password
				showDialog('{lang acan_weixin:bindfailure}{lang acan_weixin:wrongpassword}', 'alert');
				break;
			case '3':
				showDialog('{lang acan_weixin:bindfailure}{lang acan_weixin:bindedyet}', 'alert');
				break;
			case '4':
				showDialog('{lang acan_weixin:bindfailure}{lang acan_weixin:fatalerror}', 'alert');
				break;
			case '10':
				showDialog('{lang acan_weixin:bindsuccess}', 'right', '', redirect);
				break;
			case '11':
				showDialog('{lang acan_weixin:bindfailure}{lang acan_weixin:username_duplicate}', 'alert');
				break;
			case '12':
				showDialog('{lang acan_weixin:bindfailure}{lang acan_weixin:members_add_illegal}', 'alert');
				break;
			case '13':
				showDialog('{lang acan_weixin:bindfailure}{lang acan_weixin:members_username_protect}', 'alert');
				break;
			case '14':
				showDialog('{lang acan_weixin:bindfailure}{lang acan_weixin:members_email_illegal}', 'alert');
				break;
			case '15':
				showDialog('{lang acan_weixin:bindfailure}{lang acan_weixin:members_email_domain_illegal}', 'alert');
				break;
			case '16':
				showDialog('{lang acan_weixin:bindfailure}{lang acan_weixin:members_email_duplicate}', 'alert');
				break;
			case '17':
				showDialog('{lang acan_weixin:bindfailure}{lang acan_weixin:members_add_passwordwrong}', 'alert');
				break;
			default:
				showDialog(res);
				break;
		}
	}
	function redirect() {
		location.href = '{$referer}';
	}
	function checkblank(form) {
		var controls;
		var obj=form;
		if(form == 'binda') {
			controls = new Array('save[username]', 'save[password]');
		} else {
			controls = new Array('save[username]', 'save[password]', 'password', 'save[email]');
		}
		for(i=0; i<controls.length; i++) {
			var str = "document." + form + '["' + controls[i]+'"]';
			obj = eval(str);
			if(obj.value == '') {
				obj.focus();
				return false;
			}
		}
		return true;
	}
</script>
{subtemplate common/footer}